package com.yonghui.summer.dao.demo;


import com.yonghui.summer.annotation.Dao;
import com.yonghui.summer.annotation.DaoSkip;
import com.yonghui.summer.dao.demo.provider.UserProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @auther yangchuan
 * @date 2021-03-22 15:16
 */
//转换android dao 用@Dao
@Dao
@Component
public interface UserDao {

    //跳过android dao 用DaoSkip
    @DaoSkip
    List<User> findBySex(@Param("sex") Integer sex, @Param("name") String userName);

    //静态简单sql
    @Select("select * from user where name=#{user.usrName}")
    List<User> findByName(@Param("user") User user);


    //复杂的动态sql
    @SelectProvider(type = UserProvider.class,method = "findByName")
    List<User> findByParams(@Param("name") String name);

    @Insert("insert into user (username) value(#{aa})")
    int add(@Param("aa")String aa);
}
